﻿namespace AutoTest.Core.TestRunners.XUnit
{
    using log4net;
    using Xunit;

    public class XUnitTestRunner : ITestRunner
    {
        static readonly ILog _logger = LogManager.GetLogger(typeof(XUnitTestRunner));

        public TestRunResults RunTests(string assemblyName)
        {
            _logger.InfoFormat("Running unit tests using {0} against assembly {1}.", typeof(XUnitTestRunner).Name,assemblyName);
            var logger = new XUnitRunnerLogger();
            using(var wrapper = new ExecutorWrapper(assemblyName, null, false))
            {
                var runner = new TestRunner(wrapper, logger);
                runner.RunAssembly();
            }
            return new TestRunResults(logger.Results);
        }
    }
}